<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="content">设置</block>
		</cu-custom>
		<view class="padding">
			<view class="item padding-lg crow bg-white radius-xl margin-bottom"
				@tap="$utils.$page.open('/pages/user/account/bind', true)">
				<view class="left text-left">账户安全</view>
				<view class="right text-right"></view>
				<text class="cuIcon-right"></text>
			</view>
			<view class="item padding-lg crow bg-white radius-xl margin-bottom" @tap="clearCache">
				<view class="left text-left">清除缓存</view>
				<view class="right text-right"></view>
			</view>
			<view class="item padding-lg crow bg-white radius-xl margin-bottom" 
			@tap="$utils.$page.open('/pages/article/content?alias=user_agreement')">
				<view class="left text-left">用户协议</view>
				<view class="right text-right"></view>
				<text class="cuIcon-right"></text>
			</view>
			<view class="item padding-lg crow bg-white radius-xl margin-bottom" 
			@tap="$utils.$page.open('/pages/article/content?alias=privacy')">
				<view class="left text-left">隐私政策</view>
				<view class="right text-right"></view>
				<text class="cuIcon-right"></text>
			</view>
			<view class="item padding-lg crow bg-white radius-xl margin-bottom" 
			@tap="$utils.$page.open('/pages/article/content?alias=about')">
				<view class="left text-left">关于我们</view>
				<view class="right text-right"></view>
				<text class="cuIcon-right"></text>
			</view>

			<view class="padding margin-top-lg" v-if="hasLogin">
				<view class="flex flex-direction">
					<button class="cu-btn bg-red lg round" @click="outLogin">退出账号</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapState, mapGetters } from 'vuex'
export default {
	computed: {
		...mapGetters([
			'hasLogin'
		]),
		...mapState({
			USERINFO: state => state.USER.USERINFO,
			STATICTIS: state => state.USER.STATICTIS,
		})
	},
	data() {
		return {
			pageLoading: false,

		};
	},
	onLoad() {
	},
	methods: {
		clearCache(){
			this.$utils.$message.success('清除成功');
			this.$store.dispatch('clearGlobalstatus');
			// #ifdef H5
			setTimeout(()=>{
				window.location.reload();
			},500)
			// #endif
		},
		outLogin(){
			uni.showModal({
				title: '提示',
				content: '是否退出登录？',
				success: res => {
					if (res.confirm) {
						this.$store.dispatch('clearUserInfo');
						this.$store.dispatch('clearGlobalstatus');
						this.$utils.useStorage().remove('finance');
						this.$utils.$page.re('/pages/index/index');
					}
				}
			})
		}
	}
}
</script>

<style lang="less" scoped>
	.item {
		width: 100%;

		.left {
			width: 25%;
		}

		.right {
			flex: 1;
		}
	}
</style>
